﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace MyFirstCastle.Web.Models
{
    using System;
    using Castle.ActiveRecord;

    [ActiveRecord]
    public class Product : ActiveRecordBase
    {

        [PrimaryKey]
        public int Id
        {
            get;
            set;
        }

        [Property]
        public string Name
        {
            get;
            set;
        }

        [Property]
        public decimal Price
        {
            get;
            set;
        }

        [BelongsTo("SupplierId")]
        public Supplier Supplier
        {
            get;
            set;
        }

        public static Product[] FindAll()
        {
            return (Product[])FindAll(typeof(Product));
        }

        public static Product FindById(int id)
        {
            return (Product)FindByPrimaryKey(typeof(Product), id);
        }
    }

}
